package cn.zaichi.edu.excelcommon.style.impl;

import cn.zaichi.edu.excelcommon.style.CellStyle;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.HorizontalAlignment;

public class DefultCellStyle implements CellStyle {
    @Override
    public HSSFCellStyle getCellStyle(HSSFWorkbook workbook) {
        //创建单元格样式
        HSSFCellStyle cell_style = workbook.createCellStyle();

        cell_style.setAlignment(HorizontalAlignment.CENTER);
        //设置边框属性
        cell_style.setBorderBottom(BorderStyle.MEDIUM); //下边框
        cell_style.setBorderLeft(BorderStyle.MEDIUM);//左边框
        cell_style.setBorderTop(BorderStyle.MEDIUM);//上边框
        cell_style.setBorderRight(BorderStyle.MEDIUM);//右边框

        //自定义字体颜色, 同单元格样式
        HSSFFont font = workbook.createFont();
        //font.setFontHeightInPoints((short) 9);
        //字体设置为Arial
        font.setFontName(HSSFFont.FONT_ARIAL);

        //将字体颜色设为白色
        //font.setColor((short)9);
        cell_style.setFont(font);
        return cell_style;
    }
}
